#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#

d = {"dk1": "v1", "dk2": "v2"}

# d.clear()     # 清空字典
d2 = d.copy()
d["dk3"] = "v3"
print(d.get("dk3"))  # v3
print(d["dk3"])  # v3
print(d.keys())  # dict_keys(['dk1', 'dk2', 'dk3'])
print(d.values())  # dict_values(['v1', 'v2', 'v3'])

d.setdefault("dk4", "d333")  # 如果值存在不修改，不存在则添加
d.update(dk5="v5")   # 不存在则直接添加
d.update(dk4="v4")   # 存在，则会直接修改值

d["dk4"] = "vv4"   # 与 d.update(dk4="v4") 相等
print(d)
